/*----------------------------------------------------------------------------

	Copyright (c) 2006, Creator of the Cant Project.
	All rights reserved.

	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions are met:

	+ Redistributions of source code must retain the above copyright notice,
	this list of conditions and the following disclaimer.

	+ Redistributions in binary form must reproduce the above copyright notice,
	this list of conditions and the following disclaimer in the documentation
	and/or other materials provided with the distribution.

	+ Neither the name of the Creator of the Cant Project nor the names of its
	contributors may be used to endorse or promote products derived from this
	software without specific prior written permission.

	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
	AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
	ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
	LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
	CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
	POSSIBILITY OF SUCH DAMAGE.

----------------------------------------------------------------------------*/

#ifndef	_DEPEND_HPP_
#define	_DEPEND_HPP_

#include	<string>
#include	<vector>

#include	"../util/log.hpp"
#include	"../util/stringiter.hpp"



/**
	Represents the chain of dependencies of a project's targets.
	
	
	@version	0.1
	@author		<a href="mailto:cant.project@gmail.com">Mikey</a>
*/
class Dependency
{
	private:
		/**
			List of dependencies.
			
			Each element in the list is unique.
		*/
		std::vector<std::string>			m_vectorDependencies;
		
		
	public:
		/**
			Type of dependency list.
			
		*/
		typedef	std::vector<std::string>	typeDependencyList;
		
		
		/**
			Default constructor.
			
		*/
		Dependency(void );
		
		
		/**
			Constructor.
			
		*/
		Dependency(const std::string& );
		
		
		/**
			Copy constructor.
			
		*/
		Dependency(const Dependency& );


		/**
			Assignment operator.
		
		*/
		Dependency&	operator=(const std::string& );


		/**
			Assignment operator.
	
		*/
		Dependency&	operator=(const Dependency& );
		
		
		/**
			Copies dependencies from a string.
			
		*/
		void	copy(const std::string& );
		
		
		/**
			Copies the state of another dependency.
			
		*/
		void	copy(const Dependency& );
		
		
		/**
			Adds new a dependency.
			
			If the dependency already exists it is not added.
		*/
		void	add(const std::string& );
		
		
		/**
			Adds the contents of another dependency.
			
		*/
		void	add(const Dependency& );
		
		
		/**
			Indicates whether a named dependency exists.
			
		*/
		bool	contains(const std::string& );
		
		
		/**
			Gives the number of dependencies.
			
		*/
		int	size(void ) const;
		
		
		/**
			Gives the list of dependencies.
			
		*/
		std::vector<std::string>	getDependencies(void ) const;

		
		/**
			Gives the indexed dependency.
			
		*/
		std::string	operator[](int ) const;
		
		
	private:
		/**
			Adds a single dependency string.
			
			If the string is already a dependency it is not added again. The
			string is not parsed for multiple dependencies - it is assumed to
			be a single dependency.
			
		*/
		void	addInternal(const std::string& );
};

#endif
